home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 003 / dbtools.lbr / FUNCLIB.CQD / FUNCLIB.CMD
Encoding:
Text File  |  1986-08-05  |  4.4 KB  |  126 lines

  1. * <<<=======================================================================>>>
  2. *     This program is Copyrighted and the Sole Property of Keith R. Plossl
  3. *            Program Name    : FUNCLIB.CMD
  4. *            Author        : Keith R. Plossl
  5. *            Date Written    : March 1984
  6. *
  7. *  <++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
  8. *  <           C O P Y R I G H T E D   S O F T W A R E   N O T I C E        >
  9. *  <           =====================================================        >
  10. *  <  This software is copyrighted under the laws of the United States of   >
  11. *  <  America and all rights are reserved by Keith R. Plossl.  This program >
  12. *  <  may be freely copied for non-commercial use provided the title block, >
  13. *  <  modification history and this notice remain intact.  Copying this     >
  14. *  <  program for Resale or for any other commercial purpose is STRICTLY    >
  15. *  <  FORBIDDEN and subject to federal prosecution.       KRP 3/1/84        >
  16. *  <++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
  17. *
  18. *                 M O D I F I C A T I O N    H I S T O R Y
  19. *
  20. *      Date            What                Who
  21. *
  22. * <<<=======================================================================>>>
  23. *
  24. * This program is a general function library for DBASE II.  This file
  25. * will need to have the function called by a name to execute the case.
  26. * Load the five character function code in a variable called FUNCTION.
  27. * Load the parameters as required by the function needed and say: DO FUNCLIB
  28. *
  29. *                  >>>> ----- W A R N I N G ----- <<<<
  30. *
  31. *  THE FOLLOWING IS LIST OF VARIABLES USED BY THIS LIBRARY.  CONSIDER THEM
  32. *  TO BE RESERVED WORDS OR YOUR VARIABLES WITH THE SAME NAME WILL BE GONE.
  33. *
  34. *        FLD
  35. *        C:CNT               
  36. *        C:NUM    
  37. *        ENDS
  38. *           SPCD
  39. *
  40. do case
  41. * <<<=======================================================================>>>
  42. *
  43. *          ----- >>> Lower Case ASCII Function <<< -----
  44. *     -----------------------------------------------------------
  45. *     | Function Call: LCASE           Input Parameters: FIELDV |
  46. *     |                    Output Variable: FIELDV |
  47. *     -----------------------------------------------------------
  48. *
  49.     case !(FUNCTION) = 'LCASE' .AND. TYPE(FIELDV) <> 'U'
  50.         store 1        to C:CNT
  51.         store len(trim(FIELDV)) to ENDS
  52.         do while C:CNT <= ENDS
  53.             store rank($(FIELDV,C:CNT,1)) to C:NUM
  54.             if C:NUM >= 65 .and. C:NUM <= 90
  55.                 if C:CNT = 1
  56.                     store CHR(C:NUM+32) to FLD
  57.                 else
  58.                     store FLD + CHR(C:NUM+32) to FLD
  59.                 endif
  60.             else
  61.                 store FLD + CHR(C:NUM) to FLD
  62.             endif
  63.             store C:CNT + 1 to C:CNT
  64.         enddo
  65.         store FLD to FIELDV
  66.     release 
  67. * <<<=======================================================================>>>
  68. *
  69. *        ----- >>> Normalize Case ASCII Function <<< -----
  70. *     -----------------------------------------------------------
  71. *     | Function Call: NORMA           Input Parameters: FIELDV |
  72. *     |                    Output Variable: FIELDV |
  73. *     -----------------------------------------------------------
  74. *
  75.     case !(FUNCTION) = 'NORMA' .AND. TYPE(FIELDV) <> 'U'
  76.         store 2        to C:CNT
  77.         store F        to SPCD
  78.         store len(trim(FIELDV)) to ENDS
  79.         store $(!(FIELDV),1,1)    to FLD
  80.         do while C:CNT <= ENDS
  81.             store rank($(FIELDV,C:CNT,1)) to C:NUM
  82.             if C:NUM >= 65 .and. C:NUM <= 90
  83.                 store C:NUM + 32 to C:NUM
  84.             endif
  85.             if C:NUM >= 97 .and. C:NUM <= 122
  86.                 if SPCD
  87.                     store FLD + !(CHR(C:NUM)) to FLD
  88.                     store F to SPCD
  89.                 else
  90.                     store FLD + CHR(C:NUM) to FLD
  91.                 endif
  92.             else
  93.                 if C:NUM = 32
  94.                     store T to SPCD
  95.                 else
  96.                     store F to SPCD
  97.                 endif
  98.                 store FLD + CHR(C:NUM) to FLD
  99.             endif
  100.             store C:CNT + 1 to C:CNT
  101.         enddo
  102.         store FLD to FIELDV
  103.     release FLD, C:CNT, C:NUM, ENDS, SPCD
  104. * <<<=======================================================================>>>
  105. *
  106. *        ----- >>>  Otherwise Undefined <<< -----
  107. *
  108.     otherwise
  109.         store 'UNKNOWN' to FUNCTION
  110.         
  111. endcase
  112. if FUNCTION <> 'UNKNOWN'
  113.     release FUNCTION
  114. endif
  115. return
  116. * <<<=======================================================================>>>
  117. *
  118. *           End of DBASE II  General Function Library
  119. *
  120. * <<<=======================================================================>>>
  121. *     This program is Copyrighted and the Sole Property of Keith R. Plossl
  122. * <<<=======================================================================>>>
  123. *
  124.  
  125.